#ifndef __AS_TABLEBAR__H__
#define __AS_TABLEBAR__H__

#include "ASButton.h"


#define AS_TABLEBAR_MAX_ITEMS 8

typedef enum
{
    AS_TABLEBAR_SHOW_HORIZONTAL,
    AS_TABLEBAR_SHOW_VERTICAL,

    AS_TABLEBAR_SHOW_MAX
} as_tablebar_show_type;

typedef enum
{
    AS_TABLEBAR_TEXT_TYPE,//text button
    AS_TABLEBAR_IMAGE_TYPE,//image button

    AS_TABLEBAR_TYPE_MAX
} as_tablebar_src_type;

typedef void (*table_item_cb)(void);
typedef void (*table_cb)(ASINT idx);

typedef struct
{
    /* base */
    as_control base;

    /* attributes */
    as_tablebar_src_type type;
    ASINT max_item_counts;
    ASINT cur_item_counts;
    ASINT focus_idx;
    ASUINT item_w;
    ASUINT item_h;
    as_button* items[AS_TABLEBAR_MAX_ITEMS];
    table_cb callback;
    table_item_cb item_callback;
    as_image* bg_img;
    as_image* focus_bg_img;
    ASUINT bg_color;
    ASUINT focus_bg_color;
    ASINT bg_frame_color;
    as_tablebar_show_type show_type;


    /* methods */
    as_ret (*change_focus_idx)(as_control* ctrl_p, ASINT idx);
    as_ret (*change_to_next)(as_control* ctrl_p);
    as_ret (*change_to_prev)(as_control* ctrl_p);
    as_button* (*add_item)(as_control* ctrl_p, ASWSTR param1, ASWSTR param2, ASWSTR param3, ASUINT img_src_type);
    as_button* (*get_item)(as_control* ctrl_p, ASINT idx);
    as_ret (*set_bg_img)(as_control* ctrl_p, as_image_src_type type, ASWSTR path);
    as_ret (*set_bg_color)(as_control* ctrl_p, ASUINT color);
    as_ret (*set_focus_bg_color)(as_control* ctrl_p, ASUINT color);
    as_ret (*set_focus_bg_img)(as_control* ctrl_p, as_image_src_type type, ASWSTR path);
    as_ret (*set_focus_bg_offset)(as_control* ctrl_p, ASINT x_off, ASINT y_off);
    as_ret (*set_show_type)(as_control* ctrl_p, as_tablebar_show_type show_type);
    as_ret (*set_cb)(as_control* ctrl_p, table_cb cb);
    as_ret (*set_item_cb)(as_control* ctrl_p, table_item_cb cb);
} as_tablebar;


/*
 *	[description] create a table bar control
 *  [param] paint_buf : which buffer do you want to paint
 *  [param] area : area of this control
 *  [param] item_count : item counts of table bar
 *  [param] type : as_tablebar_src_type
 *  [param] show_type : as_tablebar_show_type
 *  [return] as_tablebar* : if NULL , means create failed.
 *                       else return the pointer of scroll text.
 */
as_tablebar* as_ctrl_tablebar_create(as_rect area, ASINT item_count, as_tablebar_src_type type, as_tablebar_show_type show_type);

/*
 *	[description] destroy an existed table bar
 *  [param] as_tablebar : pointer of table bar control
 *  [return] as_ret : AS_OK means destroy successful,otherwise are abnormal.
 */
as_ret as_ctrl_tablebar_destroy(as_tablebar* ctrl_tablebar_p);

#endif//__AS_TABLEBAR__H__